import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
import { useGlobSetting } from '/@/hooks/setting';
const glob = useGlobSetting();
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '品牌名称',
    align: 'center',
    dataIndex: 'name',
  },
  {
    title: '品牌logo',
    align: 'center',
    dataIndex: 'logo',
    customRender: ({ text }) => {
      if (!text) {
        return text;
      }
      text = glob.viewUrl + text;
      return render.renderImage({ text });
    },
  },
  {
    title: '状态',
    align: 'center',
    dataIndex: 'status',
    customRender: ({ text }) => {
      return render.renderDict(text, 'wms_status');
    },
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '品牌名称',
    field: 'name',
    component: 'Input',
    dynamicRules: () => {
      return [{ required: true, message: '请输入品牌名称!' }];
    },
  },
  {
    label: '品牌logo',
    field: 'logo',
    component: 'JImageUpload',
    componentProps: {
      fileMax: 1, // 最多上传1个文件
      multiple: false, // 不允许多文件上传
      responsePath: 'result.url', // 返回路径
      accept: 'image/*', // 只接受图片文件
    },
  },
  {
    label: '状态',
    field: 'status',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'wms_status',
    },
    dynamicRules: () => {
      return [{ required: true, message: '请输入状态!' }];
    },
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  name: { title: '品牌名称', order: 0, view: 'text', type: 'string' },
  logo: { title: '品牌logo', order: 1, view: 'text', type: 'string' },
  status: { title: '状态', order: 2, view: 'text', type: 'string' },
};

/**
 * 流程表单调用这个方法获取formSchema
 * @param param
 */
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
